import { get, post, del, put } from '../utils/request'

// 问题列表
export const geQuestiontList = (params) => {
  // 支持以下参数：
  // keyword: 搜索关键字
  // status: 专家状态
  // tagId: 专业领域
  // page: 当前页码
  // limit: 每页条数
  // sort: 排序方式
  return post('/question/list', {
    keyword: params.keyword || '',
    status: '',
    // status: params.status || '',
    tagId: params.tagId || '',
    page: params.page || 1,
    limit: params.limit || 10,
    uid: params.uid || '',
    type: params.type || ''
  })
}
// 查询标签列表
export const getSpecialtyTag = () => {
  return get('/specialtyTag/list')
}

// 取热门专业标签及其问题数量
export const getQuestionHotTag = () => {
  return get('/question/hot')
}


// 查询标签Tree
export const getSpecialtyTagTree = () => {
  return get('/specialtyTag/tree')
}

// 查看问题详情
export const getQuestionInfo = (id) => {
  return get(`/question/detail/${id}`)
}

// 热门问题
export const getQuestionHot = () => {
  return get('/question/hot')
}

// 创建问题
export const postCreateQuestion =  (params) => {
  return post('/question/add', params)
}

// 提交回答
export const postAnswerQuestion = (params) => {
  return post('/question/answer', params)
}

// 分页获取单个问题的回答列表，支持筛选最佳答案，按日期排序
export const getAnswerList =  (params) => {
  return get('/question/answer/page', params)
}

// 关注/取消关注问题
export const postQuestionLlike =  (params) => {
  return get('/question/like', params)
}
// 关注/取消关注回答
export const postLlike =  (params) => {
  return get('/question/answer/like', params)
}

// 编辑回答
export const postEditAnswer =  (params) => {
  return post('/question/answer/edit', params)
}

// 选择最佳答案
export const postBestAnswer =  (params) => {
  return get('/question/best-answer', params)
}

// 关闭问题
export const postCloseQuestion =  (params) => {
  return post('/question/close', params)
}

// 举报问题
export const postReportQuestion =  (params) => {
  return post('/question/report', params)
}

// 举报回答
export const postReportAnswer =  (params) => {
  return post('/question/answer/report', params)
}

// 删除回答
export const deleteAnswer = (id) => {
  return del('/question/answer/delete/'+id)
}

// 删除问题
export const deleteQuestion = (id) => {
  return del('/question/delete/'+id)
}


// 编辑问题
export const updateQuestion = (params) => {
  return post('/question/update/', params)
}

// 专家统计
export const getExpertStatistics = (params) => {
  return get('/expert/statistics/ranking', params)
}
// 用户提交举报
export const postReportaddReport =  (params) => {
  return post('/report/addReport', params)
}